package cn.lee.demo;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import cn.lee.demo.receiver.SmsReceiver;
import cn.lee.demo.services.IncomingCallReceiverService;
import cn.lee.demo.services.SmsReceiverService;

public class ThreeActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.threeactivity);
    }
    public void regiset(View v) {
//        Intent myintent = new Intent(this, SmsReceiverService.class);
//        myintent.setAction("android.provider.Telephony.SMS_RECEIVED");
        Intent myintent = new Intent(this, IncomingCallReceiverService.class);
        myintent.setAction("android.intent.action.PHONE_STATE");
        this.startService(myintent);
        Toast.makeText(this, "启动服务", 0).show();
    }

    public void unregiset(View v) {
//        Intent myintent = new Intent(this, SmsReceiverService.class);
//        myintent.setAction("android.provider.Telephony.SMS_RECEIVED");
        Intent myintent = new Intent(this, IncomingCallReceiverService.class);
        myintent.setAction("android.intent.action.PHONE_STATE");
        this.stopService(myintent);
        Toast.makeText(this, "停止服务", 0).show();
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
//        if (receiver != null && isregiset) {
//            unregisterReceiver(receiver);
//            isregiset = false;
//            Toast.makeText(this, "解注册成功", 0).show();
//        }
    }

}
